<template>
	<view class="y">
		<view class="y" v-for="(item,index) in list">
			<view class="x" style="padding: 10px 10px;" v-if="item.my==2">
				<view style="flex: 1;margin-right: 10px;">{{item.name}}</view>
				<image src="../../static/logo.png" style="width:80rpx;height: 80rpx;"></image>
			</view>
			<view class="x" style="padding: 10px 10px;" v-if="item.my==1">
				<image src="../../static/logo.png" style="width:80rpx;height: 80rpx;"></image>
				<view style="flex: 1;margin-left: 10px;">{{item.name}}</view>
			</view>
		</view>
 		<view style="position: absolute;bottom: 0;width: 100vw;height: 120rpx;background-color:#000 ;" class="">
 			<input style="height: 40px;border-radius: 40px;padding-left:10px ;" placeholder="请输入"
 				v-model="sum" />
 			<view style="" @click="song">发送</view>
 		</view>
 	</view>
 </template>

 <script>
	export default {
		data() {
			return {
				sum: '',
				list: []
			}
		},
		methods: {
			send() {
				this.list.push({
					my: 2,
					name: this.sum
				})
				uni.showLoading({
					title: "发送中"
				})
				uni.request({
					url: "https://apis.tianapi.com/robot/index?key=3ea9ff76314992e38e67287a7ab5bb27&uniqueid=landingsheng1234&question=" +
						this.sum,
					success: (res) => {
						console.log(res)
						uni.hideLoading()
						this.sum = ''
						this.myList.push({
							my: 1,
							name: res.data.result.reply
						})
					}
				})
			}

		}
	}
</script>

<style>
	.x {
		display: flex;
		flex-direction: row;
	}

	.y {
		display: flex;
		flex-direction: column;
	}
</style>